<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../../vue.js"></script>
    <link rel="stylesheet" href="./a.css" />
</head>

<body>
    <div id="app">
        <input type="text" v-model="myadd" />
        <button @click="btn">点击</button>
        <ul v-show="list.length">
            <li v-for="(item,index ) in list">
                {{item}}--
                <button @click="del(index)">删除</button>
            </li>
        </ul>
        <div v-show="!list.length">没有了</div>
    </div>

    <script>
        new Vue({
            el: "#app",
            data: {
                myadd: "",
                list: ["a", "b"],
            },
            methods: {
                btn() {
                    console.log(this.myadd);
                    this.list.push(this.myadd);
                    this.myadd = "";
                },
                del(index) {
                    console.log("del", index);
                    this.list.splice(index, 1);
                },
            },
        });
    </script>

    <!--  <div id="app">
        <input type="text" v-model="myadd" />
        <button @click="btn">点击</button>

        <ul>
            <li v-for="(item,index) in list">
                {{item}}--
                <button @click="del(index)">删除</button>
            </li>
        </ul>
    </div>

    <script>
        new Vue({
            el: "#app",
            data: {
                list: ["a", "b"],
                myadd: "",
            },
            methods: {
                btn() {
                    console.log(this.myadd);
                    this.list.push(this.myadd);
                    this.myadd = "";
                },
                del(index) {
                    console.log("del", index);
                    this.list.splice(index, 1);
                },
            },
        });
    </script>
 -->
    <!-- <div id="box">
        <input type="text" v-model="myadd" /> -->
    <!-- <input type="text" class="add" /> -->
    <!-- <button @click="btn">点击</button>
        <ul>
            <li v-for="(item,index) in datalist">
                {{item}}--
                <button @click="del(index)">删除</button>
            </li>
        </ul>
    </div> -->

    <!-- <script>
        new Vue({
            el: "#box",
            data: {
                datalist: ["a", "b", "c", "d"],
                myadd: "",
                // add: "",
            },
            methods: {
                btn() {
                    console.log(this.myadd);
                    this.datalist.push(this.myadd);
                    // this.add.push(this.myadd);
                    this.myadd = "";
                },
                del(index) {
                    console.log("del", index);
                    this.datalist.splice(index, 1);
                },
            },
        });
    </script> -->
</body>

</html>